/**
 * Copyright (c) 2010-2011 julewa.com.  
 * All rights reserved. 
 * 
 * @author Huang Benhua
 * @date 2011-7-20
 * 
**/
package com.julewa.db.checkers;

import com.julewa.db.DataState;

public class _StringChecker extends DataStateChecker{
	private int lenMin,lenMax;
	protected void _init() {
		if(checkMin)this.lenMin = (int)min;
		if(checkMax)this.lenMax = (int)max;
	};
	public DataState _check(Object obj){ 
		String str = (String)obj;
		if(checkMin && lenMin > str.length()){
			if(str.length() < 1){
				return DataState.IS_EMPTY;
			}else{
				return DataState.TOO_SHORT;
			}
		}
		//string 一定是要 checkMax的
		if(lenMax < str.length()){
			return DataState.OVER_SIZE;
		}
//		if(checkFormat){
//			throw new TODO("check format");
//		}
		return DataState.NORMAL;
	};
}
